package com.jy.appmarket.adapter;

import com.jy.appmarket.R;
import com.jy.appmarket.model.ImageFloderInfo;
import com.jy.appmarket.utils.GalleryImageLoader;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

public class GalleryPopupWindowAdapter extends SimpleBaseAdapter<ImageFloderInfo>{

	public GalleryPopupWindowAdapter(Context context) {
		super(context);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ImageFloderInfo info = mList.get(position);
		ViewHolder holder;
		if (convertView == null) {
			convertView = getInflater().inflate(R.layout.item_gallery_popup_window, parent, false);
			holder = new ViewHolder();
			holder.itemIcon = convertView.findViewById(R.id.item_icon);
			holder.itemName = convertView.findViewById(R.id.item_name);
			holder.itemCount = convertView.findViewById(R.id.item_count);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		
		holder.itemName.setText(info.getName().replace("/", ""));
		holder.itemCount.setText(info.getCount() + "张图片");
		GalleryImageLoader.getInstance(3, GalleryImageLoader.Type.LIFO).loadImage(info.getFirstImagePath(), holder.itemIcon);
		
		return convertView;
	}

	private static class ViewHolder {
		private ImageView itemIcon;
		private TextView itemName;
		private TextView itemCount;
	}
}
